// DatePicker

@import '../../style/themes/default';
@import '../../style/mixins/index';
@import './param';

@mixin date-picker {
  width: 100%;
}

@mixin date-picker-portal {
  $prefix: $--x-date-picker-portal-prefix;
  margin: 0.0625rem 0;
  font-size: $--x-date-picker-font-size;
  color: $--x-text;
  border: $--x-date-picker-border;
  border-radius: $--x-border-radius;
  box-shadow: $--x-box-shadow-light;
  background-color: $--x-background;
  width: 16rem;
  display: flex;
  flex-direction: column;
  font-size: $--x-font-size-small;
  &.date-time {
    width: 27rem;
  }
  &.date-hour {
    width: 19.75rem;
  }
  &.date-minute {
    width: 23.375rem;
  }
  &-content {
    display: flex;
  }
  &-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem;
    border-bottom: $--x-border-width solid $--x-border;
  }
  &-preset {
    display: flex;
    align-items: center;
    justify-content: center;
    border-top: $--x-border-width solid $--x-border;
    > x-button {
      flex: 1;
    }
  }
  &-year-month {
    flex: 1;
    text-align: center;
  }
  &-body {
    padding: 0.4rem;
  }
  &-footer {
    display: flex;
    justify-content: flex-end;
    border-top: $--x-date-picker-border;
    padding: 0.5rem;
  }
  &-date {
    flex: 1;
  }
  &-time {
    display: flex;
    flex-direction: column;
    &-label {
      padding: 0.4rem;
      text-align: center;
      border-left: $--x-date-picker-border;
    }
    .x-time-picker-frame {
      border-width: $--x-border-width 0 0 $--x-border-width;
      box-shadow: none;
    }
  }
}

@mixin picker-date {
  &-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    th {
      font-weight: 400;
      height: 2rem;
    }
    td {
      height: 2rem;
      padding: 0.125rem 0;
      text-align: center;
      x-button .x-button {
        width: 1.625rem;
        height: 1.5rem;
        margin: 0 auto;
        border: 0.0625rem solid transparent;
        &:hover {
          background-color: $--x-primary-900;
        }
        &-activated {
          color: $--x-background-100;
          background-color: $--x-primary;
          &:hover {
            color: $--x-background-100;
            background-color: $--x-primary;
          }
        }
      }
      &.x-date-last-or-next x-button .x-button {
        color: $--x-text-400;
      }
      &.x-date-now x-button .x-button {
        color: $--x-primary;
        background-color: transparent;
        border-color: $--x-primary;
      }
    }
  }
}

@mixin picker-month {
  &-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    td {
      height: 1.875rem;
      padding: 0.125rem 0;
      text-align: center;
      x-button .x-button {
        width: 2.6rem;
        height: 1.6rem;
        margin: 0 auto;
        border: 0.0625rem solid transparent;
        &:hover {
          background-color: $--x-primary-900;
        }
        &-activated {
          color: $--x-background-100;
          background-color: $--x-primary;
          &:hover {
            color: $--x-background-100;
            background-color: $--x-primary;
          }
        }
      }
      &.x-date-last-or-next x-button .x-button {
        color: $--x-text-400;
      }
      &.x-date-now x-button .x-button {
        color: $--x-primary;
        background-color: transparent;
        border-color: $--x-primary;
      }
    }
  }
}

@mixin picker-year {
  &-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    td {
      height: 1.875rem;
      padding: 0.125rem 0;
      text-align: center;
      x-button .x-button {
        width: 2.6rem;
        height: 1.6rem;
        margin: 0 auto;
        border: 0.0625rem solid transparent;
        &:hover {
          background-color: $--x-primary-900;
        }
        &-activated {
          color: $--x-background-100;
          background-color: $--x-primary;
          &:hover {
            color: $--x-background-100;
            background-color: $--x-primary;
          }
        }
      }
      &.x-date-last-or-next x-button .x-button {
        color: $--x-text-400;
      }
      &.x-date-now x-button .x-button {
        color: $--x-primary;
        background-color: transparent;
        border-color: $--x-primary;
      }
    }
  }
}

@mixin date-range {
  width: 100%;
  &-row {
    flex: 1;
    display: flex;
    align-items: center;
  }
  &-group {
    display: inline-flex;
    flex: 1;
    width: 100%;
    font-size: $--x-date-picker-font-size;
    background-color: $--x-date-picker-background-color;
    background-image: none;
    border: $--x-date-picker-border;
    border-radius: $--x-date-picker-border-radius;
    box-shadow: $--x-date-picker-box-shadow;
    transition: all $--x-animation-duration-slow;
    .x-input-group {
      display: flex;
      align-items: center;
      > #{$--x-prefix}-icon {
        color: $--x-text-400;
        transition: all $--x-animation-duration-base;
        z-index: 2;
        padding: 0.4rem;
      }
      > x-input {
        input {
          height: inherit !important;
          line-height: inherit !important;
        }
      }
    }
    &:hover {
      @include hover();
    }
  }
  &-focus {
    .x-date-range-group {
      @include focus();
    }
  }
}

@mixin date-range-portal {
  $prefix: $--x-date-range-portal-prefix;
  margin: 0.0625rem 0;
  font-size: $--x-date-picker-font-size;
  color: $--x-text;
  border: $--x-date-picker-border;
  border-radius: $--x-border-radius;
  box-shadow: $--x-box-shadow-light;
  background-color: $--x-background;
  width: 16rem;
  display: flex;
  flex-direction: column;
  font-size: $--x-font-size-small;
  &.date-time {
    width: 27rem;
  }
  &.date-hour {
    width: 19.75rem;
  }
  &.date-minute {
    width: 23.375rem;
  }
  &-content {
    display: flex;
  }
  &-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem;
    border-bottom: $--x-border-width solid $--x-border;
  }
  &-preset {
    display: flex;
    align-items: center;
    justify-content: center;
    border-top: $--x-border-width solid $--x-border;
    > x-button {
      flex: 1;
    }
  }
  &-year-month {
    flex: 1;
    text-align: center;
  }
  &-body {
    padding: 0.4rem;
  }
  &-footer {
    display: flex;
    justify-content: flex-end;
    border-top: $--x-date-picker-border;
    padding: 0.5rem;
  }
  &-date {
    flex: 1;
  }
  &-time {
    display: flex;
    flex-direction: column;
    &-label {
      padding: 0.4rem;
      text-align: center;
      border-left: $--x-date-picker-border;
    }
    .x-time-picker-frame {
      border-width: $--x-border-width 0 0 $--x-border-width;
      box-shadow: none;
    }
  }
}
